/*
 * MainFrame.h
 *
 *  Created on: 2012-12-24
 *      Author: lijian
 */

#ifndef MAINFRAME_H_
#define MAINFRAME_H_

#include "MainFrameBase.h"
#include "Utra.h"
#include "UtraMonitorThread.h"

const int WORKER_EVENT=wxID_HIGHEST+1;

class UtraMonitorThread;

class MainFrame: public MainFrameBase {
public:
	MainFrame(wxWindow* parent, wxWindowID id = wxID_ANY,
			const wxString& title = wxEmptyString, const wxPoint& pos =
					wxDefaultPosition, const wxSize& size = wxSize(968, 662),
			long style = wxDEFAULT_FRAME_STYLE | wxTAB_TRAVERSAL);
	virtual ~MainFrame();
    
    void OnMenu(wxCommandEvent& event);
    
    void OnWorkerEvent(wxThreadEvent& event);
protected:
    bool m_opend;
	Uart m_utra;
    
    virtual void onOpenUtra( wxCommandEvent& event );
	virtual void onSendData( wxCommandEvent& event );
    virtual void onShowPorts( wxCommandEvent& event );
    virtual void onClearRecv( wxCommandEvent& event );
    virtual void onClearSend( wxCommandEvent& event );
    virtual void onResetCount( wxCommandEvent& event );
    virtual void onHexFormatChange( wxCommandEvent& event );
    DECLARE_EVENT_TABLE()
private:
    int m_recvCount;
    int m_sendCount;
    
    wxString buadRate;
    wxString parrity;
    wxString databits;
    wxString stopBits;
    
    bool m_hexFormat;
    
    UtraMonitorThread* m_monitorThread;
    
    void changeControl();
    
    void changeUartState();

    void changeCountState();
};

#endif /* MAINFRAME_H_ */
